<?php
/*
 * Creative Bulletin Board Generation 3
 * Version 1.0 Beta 1
 +------------------------------------
 * Help Application, Index Module (Frontend)
 * Started: 17 September, 2009 14:24 PM
 * Script version: 1.0
 +------------------------------------
 */

class module implements module_interface{
	public function returninitvars(){
		global $lang;
		$this->info["page_title"] = $lang->getByKey("help.index");
		$this->info["page_description"] = "From here you can obtain quick help about the website.";
		$this->info["module_version"] = "1.0";
		return $this->info;
	}

	public function construct(){
		global $perm;
		if($perm->getValue("can_view_help") == "0"){
			$this->run = false;
		}
		else $this->run = true;
	}
	
	public function run(){
		global $view, $models, $db, $lang;
		$query = $models['helpfiles']->select_all();
		$this->output_queue = "";
		while($arr = $db->fetch_array($query)){
			$arr['content_javascript_safe'] = preg_replace("#\r\n#", " ", $arr['content']);
			$arr['content_javascript_safe'] = str_replace("'", "\'", $arr['content_javascript_safe']);
			$this->output_queue .= $view->showTemplate("helpitem", $arr);
		}
		if(strlen($this->output_queue) < 1) $this->output_queue = $lang->getByKey("help.noarticles");
		$view->writeIn($view->tablePadded($lang->getByKey("help.index.title"), $this->output_queue, "help", $lang->getByKey("help.index.subtitle")));
	}

	public function destruct(){}
}
